package cn.ltpcloud.admin.web.controller;


import cn.ltpcloud.admin.web.service.SyslogService;
import cn.ltpcloud.common.annotation.Log;
import cn.ltpcloud.common.entity.AjaxResult;
import cn.ltpcloud.common.pojo.po.SysLog;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * @author jiejiebiezheyang
 * @since 2024-03-11 11:00
 */
@Tag(name = "管理-接口日志")
@RestController
@RequestMapping("/syslog")
public class SyslogController {

    @Resource
    private SyslogService syslogService;

    @PostMapping("/list")
    @Operation(summary = "日志列表")
    @PreAuthorize("hasAnyAuthority('system:log:query')")
    public AjaxResult list(@RequestBody SysLog sysLog) {
        return syslogService.list(sysLog);
    }

    @DeleteMapping("/clean")
    @Operation(summary = "清空日志")
    @Log("管理-清空日志")
    @PreAuthorize("hasAnyAuthority('system:log:clear')")
    public AjaxResult clean() {
        return syslogService.clean();
    }
}
